import * as types from '../../mutation-types'
import lazyLoading from './lazyLoading'
import setWww from './setWww'
import information from './information'
// show: meta.label -> name
// name: component name
// meta.label: display label

const state = {
  items: [
    {
      name: '页面名称设置',
      path: '/page',
      meta: {
        icon: 'fa-tachometer',
        link: 'page/page.vue'
      },
      component: lazyLoading('page/page')
    },
    //{
    //  name: '页头页脚配置',
    //  path: '/hfer',
    //  meta: {
    //    icon: 'fa-tachometer',
    //    link: 'page/hfer.vue'
    //  },
    //  component: lazyLoading('page/hfer')
    //},
    {
      name: '网站菜单设置',
      path: '/menu',
      meta: {
        icon: 'fa-search',
        link: 'page/menu.vue'
      },
      component: lazyLoading('page/menu')
    },
    //{
    //  name: '内容管理',
    //  path: '/product',
    //  meta: {
    //    icon: 'fa-search',
    //    link: 'page/product.vue'
    //  },
    //  component: lazyLoading('page/product')
    //},
    information,
    setWww
  ]
}

const mutations = {
  [types.EXPAND_MENU] (state, menuItem) {
    if (menuItem.index > -1) {
      if (state.items[menuItem.index] && state.items[menuItem.index].meta) {
        state.items[menuItem.index].meta.expanded = menuItem.expanded
      }
    } else if (menuItem.item && 'expanded' in menuItem.item.meta) {
      menuItem.item.meta.expanded = menuItem.expanded
    }
  }
}

export default {
  state,
  mutations
}
